package com.wr.online.test.model.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 * 后端统一返回对象
 *
 * @author GZHU_WANG
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {
    private long code;  //状态码
    private String message; //附加信息
    private Object data;    //返回的数据

    /**
     * 通用返回结果
     * @return
     */
    public static RespBean success(){
        return RespBean.success(null);
    }
    public static RespBean success(Object data){
        return new RespBean(RespBeanEnum.SUCCESS.getCode(),RespBeanEnum.SUCCESS.getMsg(),data);
    }
    public static RespBean error(RespBeanEnum respBeanEnum){
        return RespBean.error(respBeanEnum,null);
    }

    public static RespBean error(RespBeanEnum respBeanEnum,Object data){
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMsg(),data);
    }

}
